import screens.screen
from pygame.locals import *
import pygame
from data import items
from pygameExt import pygameext, textrect

class textScreen(screens.screen.screeninherit):
    def __init__(self, screen, message, person="", screenname=""):
        #show a picture of the character etc.
        self.message=message
        self.screen = screen
        self.currentmessage=0
        self.nextscene=0
        self.person=person
        
    def init(self):
        self.keylisteners = [screens.screen.keyListener([items.heidi,items.heibert], 'action', self.onSpace)]
        pygameext.clearSurface(self.screen)
        pygameext.textScreenWidget(self.message[self.currentmessage], self.screen)
        pygameext.Ezwrite("Press Space to continue", self.screen, 20, 300, 200, 100, 50)
        pygame.display.update()
    
    def onSpace(self, character):
            self.currentmessage+=1
            if (self.currentmessage > len(self.message)-1):
              self.nextscene = 1
              return
            pygameext.textScreenWidget(self.message[self.currentmessage], self.screen)
            pygame.display.update()

    def loop(self):
        return